package com.zengjianjun.hive.demo.service.hive.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zengjianjun.hive.demo.entity.hive.HiveUser;
import com.zengjianjun.hive.demo.mapper.hive.HiveUserMapper;
import com.zengjianjun.hive.demo.service.hive.HiveUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zengjianjun
 */
@Slf4j
@Service
@DS("hive")
public class HiveUserServiceImpl extends ServiceImpl<HiveUserMapper, HiveUser> implements HiveUserService {

    @Resource
    private HiveUserMapper hiveUserMapper;

    @Override
    public List<HiveUser> findList() {
        return this.list();
//        return hiveUserMapper.findList();
    }

    @Override
    public void saveEntity(HiveUser entity) {
        if (entity.getId() == null) {
            entity.setId(IdWorker.getId());
        }
        hiveUserMapper.saveEntity(entity);
    }
}
